package gameElements.role;

import java.awt.Graphics2D;
import java.awt.Image;

import CMD.MapCMD;
import reader.DataReader;

public class SmallBug extends Enemy
{
	/**
	 * 
	 */
	private static final long serialVersionUID = -8149592578434218825L;
	
	private static final String name = "bug_small_";
	private static final String normal = "normal_";
//	private static final String walk = "walk_";
	
	public SmallBug(int realX, int realY, int level) 
	{
		super(realX, realY, level);
		setBlood(100);
	}

	public void bulletAttack()
	{
		
	}

	public float normalWidth() 
	{
		return 0;
	}

	public float normalHeight() 
	{
		return 0;
	}


//	private transient Image now;
	private int frame = 0;
//	private int standImage = 0;
	public void drawSelf(Graphics2D g) {
//		setDirctState(DIRCT_L);

//		if(getSpeedState() != STATE_NORMAL)
//		{
//			drawWalk(g);
//			
//		}else if(getJumpState() == STATE_NORMAL)
//		{
//			drawNormal(g);
//		}else
			drawNormal(g);
			
//		g.fillRect(Math.round(getScreenX()),Math.round(getScreenY()-getHeight()), (int)getWidth(), (int)getHeight());
	}
	public void drawNormal(Graphics2D g)
	{
		
		now = DataReader.getDataReader().getImage(name + normal+ getDir() );
//		S.p(Math.round(getScreenX()),Math.round(getScreenY()-now.getHeight(null)));
		setWidth(now.getWidth(null));
		setHeight(now.getHeight(null));
		
//		frame ++;
//		if(now == null)
//		{
////			standImage = 0;
//			drawSelf(g);
//			return;
//		}
//		if(frame >= 5)
//		{
////			standImage++;
//			frame = 0;
//		}
		g.drawImage(now,Math.round(getScreenX()-getWidth()/2),Math.round(getScreenY()-now.getHeight(null)/2),null);
	}
//	private int walkImage = 0;
	public void drawWalk(Graphics2D g)
	{
		frame ++;
		if(frame >= 6)
		{
			frame = 0;
//			walkImage++;
		}
		now = DataReader.getDataReader().getImage(name+normal+getDir());
		if(now == null)
		{
//			walkImage = 0;
			drawWalk(g);
			return ;
		}
		g.drawImage(now,Math.round(getScreenX()-getWidth()/2),Math.round(getScreenY()-now.getHeight(null)/2),null);
	}
	
//	public int[] getRectangle()
//	{
//		int[] temp = {(int) (getRealX()-getWidth()/2),(int) (getRealY()-getHeight()/2),(int) (getRealX()+getWidth()/2),(int) (getRealY()+getHeight()/2)};
//		return temp;
//	}

	public void changeScreenX() {
		setScreenX(getRealX()-MapCMD.getMapCMD().getOffX());
	}

	public void changeScreenY() {
		setScreenY(getRealY()-MapCMD.getMapCMD().getOffY());
	}

	@Override
	public void attack() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void attack(int attack) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void hitOther(Role other) 
	{
		if(((Lead)other).getAttackState() == STATE_ATTACKBODY)
			back();
		else
			other.back();
		
	}
	
	
	
}
